#pragma once

#include "RaiseExceptionAction.h"

#include "InputPin.h"

namespace uml {

RaiseExceptionAction::RaiseExceptionAction(const QString& umlType)
    : Action(umlType) {}

void RaiseExceptionAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    exception_ = JsonSerializable::create<InputPin>(json.value("exception"), errorList);

}

void RaiseExceptionAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    if (exception_) {
        QJsonObject exception_json;
        exception_->toJson(exception_json);
        json.insert("exception", exception_json);
    }
}

/// <summary>
/// exception getter
/// An InputPin whose value becomes the exception object.
/// </summary>
shared_ptr<InputPin> RaiseExceptionAction::exception() const {
    return exception_;
}

/// <summary>
/// exception setter
/// An InputPin whose value becomes the exception object.
/// </summary>
void RaiseExceptionAction::setException(shared_ptr<InputPin> value) {
    exception_ = value;
}

} // namespace uml
